/*
 * Main.cpp
 *
 *  Created on: Oct 8, 2013
 *      Author: Administrator
 */

#include <iostream>
using namespace std;

#include "Ex15.h"
#include "Ex16.h"
#include "Ex17.h"
#include "Ex18.h"
#include "Ex19_1.h"
#include "Ex19_2.h"
#include "Ex20.h"
#include "Ex21_1.h"
#include "Ex21_2.h"

void runEx15();
void runEx15(){

	Ex15 e1(1, Ex15_1(2) );
	Ex15 e2 = e1;
	cout << e1.a<<"\t"<<e1.b.c<<endl;
	e2.a = 4;
	e2.b.c = 5;
	cout << e1.a<<"\t"<<e1.b.c<<endl;
}

//declaration
void runEx16_1();
Ex16 runEx16_2();
void runEx16();

void runEx16_1()
{
	Ex16 a1(3);
	Ex16 a2 = a1;
}

Ex16 runEx16_2()
{
	return *(new Ex16(1));
}

void runEx16()
{
	runEx16_1();
	Ex16 c = runEx16_2();
}

//declaration
void runEx17();

void runEx17()
{
	Ex17 a(3.0);
	a.~Ex17();
}


//declaration
void runEx18();
void runEx18()
{
	Ex18 a = Ex18(3);
	cout <<a.b<<endl;
	Ex18 b();

}


//declaration
void runEx19();
void runEx19()
{
	Ex19_1 a(1);
	Ex19_2 c(a);
	//Ex19_2 d = c;
}

//declaration
Ex20 Ex20_1();
void Ex20_2(const Ex20& a);
Ex20 Ex20_1()
{
	Ex20 a(2);
	Ex20 b = a;
	return b;
}

void Ex20_2(const Ex20& a)
{
	cout << a.b <<endl;
}

//declaration
void runEx21_1(Ex21_1 a1);
void runEx21_2(Ex21_2 a2);

void runEx21_1(Ex21_1 a1)
{
	cout << a1.a <<endl;
}

void runEx21_2(Ex21_2 a2)
{
	cout<<a2.a<<endl;
}

int main()
{
	//runEx15();
	//runEx16();
	//runEx17();
	//runEx18();
	//runEx19();
	//Ex20& a= Ex20_1();
	//Ex20_2(a);
	Ex21_1 a(3);
	Ex21_2 b(2);
	runEx21_1(a);
	runEx21_2(b);
	return 1;
}


